package folder.main.exp2.algorithms;

import java.util.Comparator;
import java.util.List;

import folder.model.network.Network;
import folder.model.node.Node;
import folder.model.virtual.VirtualNetwork;

public class MinKCenter extends Algorithm2
{
	// Algorithm
	
	public static MinKCenter minKCenter( Network network, double delayThreshold, List< VirtualNetwork > virtualNetworks )
	{
		return new MinKCenter( network, delayThreshold, virtualNetworks );
	}
	
	public MinKCenter( Network network, double delayThreshold, List< VirtualNetwork > virtualNetworks )
	{
		super( network, delayThreshold, virtualNetworks );
		
		this.comparator = new ComparatorMinKCenter();
		
		this.checkAlgorithm = this.run();
	}
	
	// Comparator
	
    private class ComparatorMinKCenter implements Comparator< Node >
    {
    	@Override
    	public int compare( Node nodeX, Node nodeY )
    	{    
    		Double delayLongestNodeX = nodeX.getDelayToNodeTargetLongest();
    		Double delayLongestNodeY = nodeY.getDelayToNodeTargetLongest();
    		
    		return delayLongestNodeX.compareTo( delayLongestNodeY );
    	}
    }
}
